﻿#ifndef GUIDETABLE_H
#define GUIDETABLE_H


#include <QWidget>
#include <QProxyStyle>
#include <QPainter>
#include <QStyleOptionTab>
#include "xlsxdocument.h"
#include <QDebug>
#include <dbHelper.h>
#include <QFileDialog>
#include <QTableWidget>
#include <QLabel>
#include <QHBoxLayout>
#include "pcrState.h"
#include <QHeaderView>
#include <QFontDatabase>
#include "dataanatool.h"
#include "labelResultWarningInfo.h"

extern QStringList     STRType;
extern QStringList     STRName;
extern QStringList     STRsys;

class GuideTable : public QWidget
{
    Q_OBJECT
public:
    GuideTable(QWidget* parent=nullptr);

    void init(PCRState *state);
    void calculate();

    void on_sum_clicked();

    void on_CSTR_clicked();

    void on_YSTR_clicked();

    void on_miniSTR_clicked();

    void on_dilute_clicked();

    void save(QString filePath);        // 传入xlsx的路径

    // 用于打印的表格
    QTableWidget* getTable1();
    QTableWidget* getTable2();

private slots:
    void on_filterChanged();            // 筛选
    void on_guidePageChanged();         // 表格2页面切换
    void on_pageChanged();              // 两个表格之间的切换
    void on_recalculate();

private:

    void createXlsx(QXlsx::Document &xlsx);

    void updateTable1();
    void updateTable2();

    void fixRow();
    void resizeRow();
    void resizeEvent(QResizeEvent *event) override;

    void refreshLabelResultInfo();


public:
    QTableWidget*   _table_data = nullptr;
    QTableWidget*   _table_plan = nullptr;
    QString         _typeTable2 = "总数";
    PCRState*       pState = nullptr;
    QVBoxLayout*    _layout;
    QWidget*        _widget_text;
    QGridLayout*    _layout_text;

    QLabel*         _label_Y;
    QLabel*         _label_AL;
    QLabel*         _label_AS;

    LabelResultInfo*         _warning_Y;
    LabelResultInfo*         _warning_AL;
    LabelResultInfo*         _warning_AS;

    QTableWidget*   _table0;



    QTableWidget*   _printTable1 = nullptr;
    QTableWidget*   _printTable2 = nullptr;

    dataanatool*    _anaTool;



};

#endif // GuideTable_H
